#
# Package.
#

package iSOCK::Controller::Integration::Components;

#
# Parent.
#

use Moose;
use namespace::autoclean;

BEGIN { extends 'iSOCK::Controller::Root' }

#
# Documentation.
#

=head1 NAME

iSOCK::Controller::Integration::Product - Product Controller for iSOCK

=head1 DESCRIPTION

[enter your description here]

=head1 METHODS

=cut

#
# Subs.
#

sub index :Path :Args(0) {
  my ( $self, $c ) = @_;

  if ( my $lol = $c->controller ( 'REST' )->product_to_component_lol ( $c, 'integration' ) ) {
    my $column   = 3;
    my @products = map { $column++ ; { label => $_->{content}, onclick => "toggle_display ( 'column_$column' )", id => "column_$column" } } grep { ! m/^(Component|Description|Type)$/x } @{$lol->[0]};

    $c->stash ( alt_navigation => 1, alt_navigation_title => 'Products', alt_navigation_items => \@products );
    
    $self->_htmlize_lol ( $lol );
    
    $c->stash ( product_to_component_lol_head =>                          shift @$lol   );
    $c->stash ( product_to_component_lol_body => [ sort { $a->[2] cmp $b->[2] } @$lol ] );
  }

  $c->forward ( qw( iSOCK::Controller::Root render_view ) );
}

#
# Documentation.
#

=head1 AUTHOR

Xavier Caron

=head1 LICENSE

This library is free software, you can redistribute it and/or modify
it under the same terms as Perl itself.

=cut

#
# End of iSOCK::Controller::Products.
#

1;
